import http from '/@lib/utils/http/request'

// pc端固定客户端授权id
const clientId = import.meta.env.VITE_APP_CLIENT_ID


export const AuthApi: any = {}

AuthApi.login = async (data: any) => {

  // if (loginRSA) {
  data = {
    ...data,
    // password: await encryptedData(data),
    clientId: data.clientId || clientId,
    grantType: data.grantType || 'password',
  }
  // }

  return http.post('/auth/login', data, {
    headers: {
      isToken: false,
      isEncrypt: true,
    },
  })
}

AuthApi.logout = () => {
  return http.post('/auth/logout')
}

AuthApi.getUserInfo = () => {
  return http.get('/authSystem/getUserInfo')
}

AuthApi.getRouters = () => {
  return http.get('/authSystem/getRouters')
}
